<?php
class WebUser extends CWebUser {	
	public function getLanguage() {
		if ($this->getState('lang') == null) {
			$lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
			$this->setLanguage($lang);
		}
		return $this->getState('lang');
	}

	public function setLanguage($lang) {
		$this->setState('lang', $lang);
	}

	public function applyPreferedLanguage() {
		Yii::app()->language = $this->getLanguage();
	}

	public function getAvalaibleLanguages() {
		return array('en' => Yii::t('site', 'english'), 'spa' => Yii::t('site', 'spanish'));
	}
	

	/**
	 * methodDescription.
	 *
	 * @return returnType returnDescription
	 */
	public function _setUp($customer) {
		
		$orcCustomer = $customer->getOrcCustomer();
		
		$this->setState('customerID'	, $customer->customerID);
		$this->setState('username'  	, $customer->loginID);
		$this->setState('currentCredit' , $orcCustomer->BALANCE);
		$this->setState('accountNumber' ,$orcCustomer->SUBSCRIBER_ID);

	}



	/**
	 * methodDescription.
	 *
	 * @return returnType returnDescription
	 */
	public function getUserName() {
		return $this->getState('username');
	}
	
	/**
	 * get current credit.
	 *
	 * @return balance Balance
	 */
	public function getBalance() {
	    return $this->getState('currentCredit');
	}
	
	/**
	 * Get Customer Id.
	 *
	 * @return accountNumber get Number
	 */
	public function getAccountNumber() {
	    return $this->getState('accountNumber');
	}

}